LIN Hall 2 Click
LIN Hall 2 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Ilic
- Date : Oct 2023.
- Type : ADC type
Software Support
Example Description
This is an example which demonstrates the use of LIN Hall 2 Click board by measuring magnetic field density and showing it in mT as well as detecting the orientation of the magnet.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.LINHall2
Example Key Functions
- linhall2_cfg_setup Config Object Initialization function.
void linhall2_cfg_setup(linhall2_cfg_t *cfg)
LIN Hall 2 configuration object setup function.
LIN Hall 2 Click configuration object.
Definition linhall2.h:123
- linhall2_init Initialization function.
err_t linhall2_init(linhall2_t *ctx, linhall2_cfg_t *cfg)
LIN Hall 2 initialization function.
LIN Hall 2 Click context object.
Definition linhall2.h:111
- linhall2_read_an_pin_voltage LIN Hall 2 read AN pin voltage level function.
err_t linhall2_read_an_pin_voltage(linhall2_t *ctx, float *data_out)
LIN Hall 2 read AN pin voltage level function.
- linhal2_set_en_pin LIN Hall 2 set EN pin state function.
void linhal2_set_en_pin(linhall2_t *ctx, uint8_t pin_state)
LIN Hall 2 set EN pin state function.
- linhal2_get_flux_density LIN Hall 2 read flux density function.
err_t linhal2_get_flux_density(linhall2_t *ctx, float *data_out)
LIN Hall 2 read flux density function.
Application Init
The initialization of ADC module and log UART.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define LINHALL2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition linhall2.h:99
#define LINHALL2_ENABLE_DEVICE
LIN Hall 2 EN pin setting.
Definition linhall2.h:80
void application_init(void)
Definition main.c:33
#define MIKROBUS_POSITION_LINHALL2
Definition main.c:27
Application Task
The demo application reads the Magnetic field density and showing it in mT as well as the orientation of the magnet.
{
float mag_flux = 0;
{
log_printf( &logger, " Magnetic flux density: %.3f[mT]\r\n", mag_flux );
if ( 0 < mag_flux )
{
log_printf( &logger, " Magnetic field oriented South \r\n\n" );
}
else
{
log_printf( &logger, " Magnetic field oriented North \r\n\n" );
}
Delay_ms ( 1000 );
}
}
@ LINHALL2_OK
Definition linhall2.h:138
void application_task(void)
Definition main.c:65
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.